package com.hongkzh.www.look.enterprise.userinfo.view.framgent;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.hongkzh.www.R;
import com.hongkzh.www.look.model.bean.AttenedBean;
import com.hongkzh.www.look.enterprise.userinfo.model.bean.MediaCompData;
import com.hongkzh.www.other.utils.SharedPreferencesUtil;
import com.hongkzh.www.other.utils.UIUtils;
import com.hongkzh.www.look.enterprise.userinfo.presenter.MediaComPresenter;
import com.hongkzh.www.view.fragment.BaseFragment;
import com.hongkzh.www.look.enterprise.userinfo.view.iview.MediaBaseInfoIView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;


/***
 *  媒体主页的简介Fragment
 */
public class MediaIntroduceFragment extends BaseFragment<MediaComPresenter> implements MediaBaseInfoIView {

    @BindView(R.id.tv_comName)
    TextView tvComName;
    @BindView(R.id.tv_comAddess)
    TextView tvComAddess;
    @BindView(R.id.tv_Tel)
    TextView tvTel;

    @BindView(R.id.iv_photo)
    ImageView ivPhoto;
    Unbinder unbinder;

    private Bundle bundle;
    private String uid, mLoginId;

    private SharedPreferencesUtil spfu;

    @Override
    protected void init() {
        setPresenter(new MediaComPresenter());

        bundle = getArguments();
        uid = bundle.getString("uid");
        Log.i("gaoshan", "媒体简介传过来的UID====" + uid);

        spfu = new SharedPreferencesUtil(UIUtils.getContext());
        mLoginId = spfu.getUserInfo().getLoginUid();

        getPresenter().GetMediaComInfo(mLoginId, uid);

    }


    @Override
    protected void setListener() {

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fagment_media_introduce;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @Override
    public void onShowMediaComInfo(MediaCompData mediaCompData) {

        if (mediaCompData != null) {
            tvComName.setText(mediaCompData.getData().getCompanyName());
            tvComAddess.setText(mediaCompData.getData().getAddress());
            tvTel.setText(mediaCompData.getData().getTel());
//            tvIntro.setText(mediaCompData.getData().getDescribe());
            Glide.with(getActivity()).load(mediaCompData.getData().getDescribe()).into(ivPhoto);
        }

    }

    @Override
    public void onShowIfAttend(AttenedBean attenedBean) {

    }

    @Override
    public void onShowNoAttend(AttenedBean attenedBean) {

    }

    @Override
    public void onError(Exception e) {

    }

    @Override
    public void onClick(View v) {

    }
}
